package com.chj.design.sk;

public class Code12_Adapter4 {
	public interface Car {
		void drive();
	}

	public interface Helicopter {
		void air();
	}

	public static class Agent implements Car {
		@Override
		public void drive() {
			System.out.println("特工开着汽车，啦啦啦。");
		}
	}

	public static class ClassAdapter extends Agent implements Helicopter {
		@Override
		public void air() {
			System.out.println("特工驾驶者飞机，呼呼呼。");
		}
	}

	public static class ObjectAdapter implements Helicopter {
		private Agent agent;

		public ObjectAdapter(Agent agent) {
			this.agent = agent;
		}

		public void drive() {
			this.agent.drive();
		}

		@Override
		public void air() {
			System.out.println("特工驾驶者飞机，呼呼呼。");
		}
	}

	public static void main(String[] args) {
		System.out.println("---------初始特工----------");
		Agent agent = new Agent();
		agent.drive();
		System.out.println("---------类适配器特工----------");
		ClassAdapter adapter = new ClassAdapter();
		adapter.air();
		adapter.drive();
		System.out.println("---------对象适配器特工----------");
		ObjectAdapter classAdapter = new ObjectAdapter(agent);
		classAdapter.drive();
		classAdapter.air();
	}
}
